<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<%
if Request("bComm")<>"restart" then
		if Session("Started") ="no" then
			Response.Redirect("..\Error.asp?ErrorCode=1")
		end if
	end if
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<%	
	On Error Resume next
	
	bComm=request("bComm")
	IDFlow = Request("IDFlow")
    Nguoitao = Request("Nguoitao")
    bMaRoot = Request("bMaRoot")
    Filename =Request("Filename")

	

	'Phancap
	MaCB = Request("MaCB")
	Hanxuly = Request("Hanxuly")

	if Hanxuly ="" then
		Hanxuly = ToFormatDate(Date + 7) 
	end if			
	yeucau = Request("Yeucau")

	bMadonvi=trim(Request("bMadonvi"))	

	nodeid = Request("id")
	Maflownode	= Request("Maflownode")
	Trangthai = Request("Trangthai")

  %>
   <script language=javascript>
	var remote=null;
	function rs(n,u,w,h,x) {
	  args="width="+w+",height="+h+",resizable=yes,scrollbars=yes,status=0";
	//  remote=window.showModalDialog(u, "", "font-family:'Timems new roman'; font-size:12; dialogWidth:30em; dialogHeight:20em");
	remote=window.open(u,n,args);	  
	if (remote != null) {
	    if (remote.opener == null)
	      remote.opener = self;
	  }
	  if (x == 1) { return remote; }
	}
	var awnd=null;
	function Show() {
	  awnd=rs('att','addright.asp?IDWorkflow=<%=IDFlow%>',400,300,1);
	}
	//bg Quang Phancap
	function openW(sObj) {
	  popupWin = window.open('Search.asp?bMadonvi=' + frmnoidung.DonVi.value,'new_page','width=300,height=300');
	}
	function openWE(sObj) {
	  popupWin = window.open('SearchE.asp?bMadonvi=' + frmedit.DonVi.value,'new_page','width=300,height=300');
	}

	function openDonVi() {

		bComm="<%=bComm%>";
		IDFlow = "<%=IDFlow%>";
		Nguoitao = "<%=Nguoitao%>";
		bMaRoot = "<%=bMaRoot%>";
		Filename ="<%=Filename%>";

		nodeid = "<%=nodeid%>";
		Maflownode = "<%=Maflownode%>";
		Trangthai= "<%=Trangthai%>";

			window.frmnoidung.target="right";
			window.frmnoidung.action="flow.asp?bComm=add&bMaRoot=" + bMaRoot + "&IDFlow=" + IDFlow + "&id=" + nodeid + "&Maflownode=" + Maflownode + "&Trangthai=" + Trangthai + "&Nguoitao=" + Nguoitao + "&Filename=" + Filename + "&bMadonvi=" + frmnoidung.DonVi.value ;	
			window.frmnoidung.submit();
	}

	function openDonViE() {

		bComm="<%=bComm%>";
		IDFlow = "<%=IDFlow%>";
		Nguoitao = "<%=Nguoitao%>";
		bMaRoot = "<%=bMaRoot%>";
		Filename ="<%=Filename%>";

		nodeid = "<%=nodeid%>";
		Maflownode = "<%=Maflownode%>";
		Trangthai= "<%=Trangthai%>";

         MaCB = "<%=MaCB%>";
         Hanxuly = "<%=Hanxuly%>";
         yeucau = "<%=yeucau%>";

			window.frmedit.target="right";
			window.frmedit.action="flow.asp?bComm=edit&bMaRoot=" + bMaRoot + "&IDFlow=" + IDFlow + "&id=" + nodeid + "&Maflownode=" + Maflownode + "&Trangthai=" + Trangthai + "&Nguoitao=" + Nguoitao + "&Filename=" + Filename + "&MaCB=" + MaCB + "&Hanxuly=" + Hanxuly + "&yeucau=" + yeucau + "&bMadonvi=" + frmedit.DonVi.value ;			
			window.frmedit.submit();
	}
	//ed Quang Phancap
</script>

  <%
	Set Cls=server.CreateObject("Vinalines.ClsFunction")	
    Response.Write "<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>"
    
    Response.Write "function view() {"
    Response.Write "frm.target='_blank';"
    Response.Write "frm.action='xemnoidung.asp?Loai=xuly&bMa=" + IDFlow + "';"
    Response.Write "frm.submit();"
    Response.Write "}"

    Response.Write "function addright() {"
	Response.Write "Show()"					
    Response.Write "}"

     Response.Write "function msg() {"
	Response.Write "alert('Số các nhánh trong một node không quá 99');"					
    Response.Write "}"

    
    Response.Write "function conf() {"
    Response.Write "if(!confirm('Bạn có muốn xoá không')){"
            Response.Write "return false;"
            Response.Write "}"
    Response.Write "}"
    
    Response.Write "function RootFlow_onclick() {"
        Response.Write "frm.target='right';"
        Response.Write "frm.action='editor/frmedit.asp?bMaRoot=" + bMaRoot + "&bMa=" + IDFlow + "&Loai=xuly&Nguoitao=" + Nguoitao + "';"
        Response.Write "frm.submit();"
    Response.Write "}"
'Them yeu cau
    If Request("bComm") = "add" Then
    Response.Write "function OnChange(){"
        Response.Write "if(frmnoidung.Chk.checked){"
            Response.Write "frmnoidung.Canbo.disabled=true;"
            Response.Write "frmnoidung.nhom.disabled=false;"
            Response.Write "frmnoidung.nhom.focus();"
        Response.Write "}"
        Response.Write "else{"
            Response.Write "frmnoidung.nhom.disabled=true;"
            Response.Write "frmnoidung.Canbo.disabled=false;"
            Response.Write "frmnoidung.Canbo.focus();"

        Response.Write "}"
    Response.Write "}"
    
        Response.Write "function CmdBack_onclick() {"
            Response.Write "frmnoidung.Target = 'right';"
            Response.Write "frmnoidung.action='flow.asp?bMaRoot=" & bMaRoot & "&IDFlow=" + IDFlow + "&Nguoitao=" + Nguoitao + "';"
            Response.Write "frmnoidung.submit();"
        Response.Write "}"
        Response.Write "function CmdOK_onclick() {"
            Response.Write "if(trim(frmnoidung.TxtThoihan.value)==''){"
                Response.Write "alert('Cho biết thời hạn');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "if(!isDate(frmnoidung.TxtThoihan.value)){"
                Response.Write "alert('Thời hạn không hợp lệ');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "frmnoidung.Target = 'right';"
            
          Response.Write "if(frmnoidung.Chk.checked){"
        Response.Write "if(frmnoidung.nhom.value==''){"
            Response.Write "alert('Cho biết nhóm xử lý');"
            Response.Write "frmnoidung.nhom.focus();"
            Response.Write "return false;"
        Response.Write "}"
              Response.Write "frmnoidung.action='node/add.asp?bNhom=ok&bMaRoot=" + bMaRoot + "&Trangthai=" + Request("Trangthai") + "&MaflowNode=" + Cls.Mahoa(Request("Maflownode")) + "&IDFlow=" + Request("IDFlow") + "&Nguoitao=" + Nguoitao + "&Filename=" + Filename + "';"
              Response.Write "}"
        Response.Write "else{"
        Response.Write "if(frmnoidung.Canbo.value==''){"
            Response.Write "alert('Cho biết người xử lý');"
            Response.Write "frmnoidung.Canbo.focus();"
            Response.Write "return false;"
        Response.Write "}"
        Response.Write "frmnoidung.action='node/add.asp?bMaRoot=" + bMaRoot + "&Trangthai=" + Request("Trangthai") + "&MaflowNode=" + Cls.Mahoa(Request("Maflownode")) + "&IDFlow=" + Request("IDFlow") + "&Nguoitao=" + Nguoitao + "&Filename=" + Filename + "';"
        Response.Write "}"
        
            Response.Write "frmnoidung.submit();"
        Response.Write "}"
    End If
    'Sua yeu cau
    If bComm = "edit" Then
        Response.Write "function CmdBack_onclick() {"
            Response.Write "frmedit.Target = 'right';"
            Response.Write "frmedit.action='flow.asp?bMaRoot=" + bMaRoot + "&IDFlow=" + IDFlow + "&Nguoitao=" + Nguoitao + "&Filename=" + Filename + "';"
            Response.Write "frmedit.submit();"
        Response.Write "}"
        Response.Write "function CmdOK_onclick() {"
            Response.Write "if(frmedit.TxtThoihan.value==''){"
                Response.Write "alert('Cho biết thời hạn');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "if(!isDate(frmedit.TxtThoihan.value)){"
                Response.Write "alert('Thời hạn không hợp lệ');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "frmedit.Target = 'right';"
            Response.Write "frmedit.action='flow.asp?bMaRoot=" + bMaRoot + "&bComm=editok&IDFlow=" + IDFlow + "&Nguoitao=" + Nguoitao + "';"
            Response.Write "frmedit.submit();"
        Response.Write "}"
        Response.Write "function CmdReset_onclick() {"
            Response.Write "if(trim(frmedit.TxtThoihan.value)==''){"
                Response.Write "alert('Cho biết thời hạn');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "if(!isDate(frmedit.TxtThoihan.value)){"
                Response.Write "alert('Thời hạn không hợp lệ');"
                Response.Write "return false;"
            Response.Write "}"
            Response.Write "frmedit.Target = 'right';"
            Response.Write "frmedit.action='flow.asp?bMaRoot=" + bMaRoot + "&trangthai=" + Request("Trangthai") + "&bComm=reset&IDFlow=" + IDFlow + "&Nguoitao=" + Nguoitao + "';"
            Response.Write "frmedit.submit();"
        Response.Write "}"
    End If
    If bComm <> "edit" And bComm <> "add" Then
        Response.Write "function CmdQuaylai_onclick() {"
            Response.Write "frm.target='right';"
            Response.Write "frm.action='frmdsflow.asp';"
            Response.Write "frm.submit();"
        Response.Write "}"
    End If
    Response.Write "</SCRIPT>"
    Set Cls=nothing

%>


<!--#include file="..\jvfunction.inc"-->
<%  
	set WFlow=server.CreateObject("Vinalines.ClsWorkflow")
	if WFlow.OpenConn (Application("StrConn")) then
		call WFlow.flow
%>
<SCRIPT ID=clientEventHandlersVB LANGUAGE=VBscript>
<!--
<%if request("bComm")="add" then%>
function TxtSearch_onchange() 
	for each pt in frmnoidung.Canbo
		if instr(1,pt.value,frmnoidung.TxtSearch.value,vbTextCompare) then
			frmnoidung.Canbo.value=pt.value
			exit for
		end if
	next
end function
<%end if%>
<%if request("bComm")="edit" then%>
function TxtSearchE_onchange() 
	for each pt in frmedit.Canbo
		if instr(1,pt.value,frmedit.TxtSearch.value,vbTextCompare) then
			frmedit.Canbo.value=pt.value
			exit for
		end if
	next
end function
<%end if%>
//-->
</SCRIPT>
<script language=VBScript runat=server>	
	Function ToFormatDate(vDate) 
        Dim vM, vD, vY
       If Not IsNull(vDate) Then
            vM = Right("0" & Month(vDate), 2)
            vD = Right("0" & Day(vDate), 2)
            vY = Right("19" & Year(vDate), 4)
            ToFormatDate = vD & "/" & vM & "/" & vY
       End If
    End Function
</script>
<%
		WFlow.CloseConn
	else
		Response.Redirect("..\Error.asp?ErrorCode=2")		
	End if
	if Err.number then
		%><p align=center><font face=Arial color=red size=4>Lỗi ! Không đặc tả 
được lỗi <br><a href=frmdsflow.asp>Quay lại</a></font><%
	End if 
	Err.Clear
%>
<%
'bg thphuc 03-03-03
	sSQL="select distinct workflow.trangthai from workflow inner join flownode on workflow.maworkflow=flownode.maworkflow where flownode.trangthaixl<>2 and workflow.maworkflow like '"& IDFlow &"' and workflow.trangthai=1"
		Set RecKtWorkflow=Server.CreateObject("ADODB.Recordset")
		RecKtWorkflow.CursorType=3
		RecKtWorkflow.CacheSize=5
		RecKtWorkflow.Open sSQL,Conn
			if RecKtWorkflow.recordcount > 0 then
				sSQL="update workflow set trangthai=0 where maworkflow like '"& IDFlow &"'"
				Conn.Execute sSQL
			end if
		RecKtWorkflow.Close
		set RecKtWorkflow	= nothing
	'ed thphuc 03-03-03
%>